// JavaScript Document

Type.registerNamespace("AjaxLab");

AjaxLab.Log4J = function(DebugZone)
{
	var instance            	=   this;
	var debug_area				=	"debugZone";			
	
	var Level					=	1;
	var IsLogEnabled 			=	false;

	var logmethod				=	"";
	var logging_text			=	"Log4J ";
	
	this.LevelTypes				=	{
										All:	0,
										Debug: 	1,
										Info:	2,
										Warn:	3,
										Error:	4,
										Fatal:	5,
										Off: 6
									};
	
	function getLevelType()
	{
		var type = "";
		if(Level == 0)
		{
			type = "All";
		}
		else if (Level ==1)
		{
			type = "Debug";
		}
		else if (Level ==2)
		{
			type = "Info";
		}
		else if (Level ==3)
		{
			type = "Warn";
		}
		else if (Level ==4)
		{
			type = "Error";
		}
		else if (Level ==5)
		{
			type = "Fatal";
		}
		return type;
	}
	
	function writeDebug(value)
	{
		if(IsLogEnabled)
		{
			instance.getDebugZone().innerHTML = logging_text+" "+new Date()+ " " + logmethod.toUpperCase()+" "+value+"<br/>"+instance.getDebugZone().innerHTML;
		}
	}
	
	this.getRootLevel			=	function()
	{
		return Level;
	}
	
	this.setRootLevel			=	function(level_value)
	{
		Level	=	level_value;
	}
	
	this.setIsDebug				=	function(isLogOn)
	{
		IsLogEnabled			=	isLogOn;
	}
	
	this.setDebugZone								=	function(debugZone)
	{
		
		debug_area		=	debugZone;
	}
			
	this.getDebugZone								=	function()
	{
				return $(debug_area);
	}
			
	
	this.Debug	=	function(value)
	{
		if(Level<=1)
		{
			logmethod		=	"debug";
			writeDebug(value);
		}
	}
	
	this.Info	=	function(value)
	{
		if(Level<=2)
		{
			logmethod		=	"info";
			writeDebug(value);
		}
	}
	
	this.Warn	=	function(value)
	{
		if(Level<=3)
		{
			logmethod		=	"warn";
			writeDebug(value);
		}
	}
	
	this.Error	=	function(value)
	{
		if(Level<=4)
		{
			logmethod		=	"error";
			writeDebug(value);
		}
	}
	this.Fatal	=	function(value)
	{
		if(Level<=5)
		{
			logmethod		=	"fatal";
			writeDebug(value);
		}
	}
	
	instance.setDebugZone(DebugZone);
}
AjaxLab.Log4J.registerClass('AjaxLab.Log4J', null, null);


